package com.hp.common.base;

import com.github.pagehelper.Page;

import java.io.Serializable;
import java.util.List;

/**
 * 分页数据实体
 *
 * @param <T>
 */
public class CommonPage<T> implements Serializable {
    /**
     *
     */
    private int pageNum;

    private int pageSize;

    private long recordCount;

    private int totalPages;

    private List<T> rows;

    public static <T> CommonPage<T> toPage(Page<T> page) {
        CommonPage<T> result = new CommonPage<T>();
        result.setTotalPages(page.getPages());
        result.setPageNum(page.getPageNum());
        result.setPageSize(page.getPageSize());
        result.setRecordCount(page.getTotal());
        result.setRows(page.getResult());
        return result;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getRecordCount() {
        return recordCount;
    }

    public void setRecordCount(long recordCount) {
        this.recordCount = recordCount;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}
